﻿<!DOCTYPE HTML>
<html>
<head>
    <title>积分商城</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="keywords" content="销冠,TopSales微信" />
    <meta name="description" content="销冠,TopSales微信,TopSales销冠" />
    <meta http-equiv="Access-Control-Allow-Origin" content="*" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Pragma" content="no-cache" />
    <base href="http://static.tops001.com/pointstore/" />
    <link href="css/owl.carousel.css" rel="stylesheet" />
    <link href="css/owl.theme.css" rel="stylesheet" />

    <script src="../jq-bs-art.js" type="text/javascript"></script>
    <script src="http://apps.bdimg.com/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script src="../kk.js" type="text/javascript"></script>
    <script src="js/PageIndex.js"></script>

    <link href="css/index.css" rel="stylesheet" type="text/css" />

    <style>
        .foot_nav .foot_ul {
            position: relative;
            height: auto;
            width: 100%;
            overflow: hidden;
            zoom:1;
        }
        .opacity{
            -webkit-animation: opacity 0.5s linear;
            animation: opacity 0.5s linear;
        }
        @-webkit-keyframes opacity {
            0% {
                opacity:0;
            }
            100% {
                opacity:1;
            }
        }
        @keyframes opacity {
            0% {
                opacity:0;
            }
            100% {
                opacity:1;
            }
        }
        /* dropload */
        .dropload-up, .dropload-down {
            position: fixed;
            margin: 0 auto;
            width: 100%;
            height: 0;
            bottom: 0px;
            background: #f0f0f0;
            color:#999;
            overflow: hidden;
            -webkit-transform: translate3d(0,0,0);
            transform: translate3d(0,0,0);
            font-size:16px
        }

        .dropload-refresh, .dropload-update, .dropload-load {
            position: absolute;
            left: 50%;
            bottom: 0;
            width: 100%;
            height: 30px;
            line-height: 30px;
            text-align: center;
            -webkit-transform: translate(-50%,0);
            transform: translate(-50%,0);
        }

            .dropload-load .loading {
                display: inline-block;
                height: 20px;
                width: 20px;
                border-radius: 100%;
                margin: 6px;
                border: 2px solid #666;
                border-bottom-color: transparent;
                vertical-align: middle;
                -webkit-animation: rotate 0.75s 0 linear infinite;
                animation: rotate 0.75s 0 linear infinite;
            }

        @-webkit-keyframes rotate {
            0% {
                -webkit-transform: rotate(0deg);
            }

            50% {
                -webkit-transform: rotate(180deg);
            }

            100% {
                -webkit-transform: rotate(360deg);
            }
        }

        @keyframes rotate {
            0% {
                transform: rotate(0deg);
            }

            50% {
                transform: rotate(180deg);
            }

            100% {
                transform: rotate(360deg);
            }
        }
    </style>

</head>
<body>
    <!-- wheel -->
    <div id="owl-demo" class="owl-carousel owl-theme">
        <!--<div class="item"><a href="award.html"><img src="images/banner-cj.jpg" /></a> </div>-->        
        <!--<div class="item"> <img src="images/banner_17.jpg?v=a10" title="" alt="" /> </div>-->
        <div class="item"> <img src="images/banner_15.jpg?v=a10" title="" alt="" /> </div>
        <!--<div class="item"> <img src="images/banner_14.jpg?v=a10" title="" alt="" /> </div>--> 
    </div>

    <!-- menu -->
    <div class="shop_top_index">
        <div class="shop_count shop_left"><a><span class="my_count">我的积分:</span><span class="shop_num" id="PointBalance">0</span></a></div>
        <div class="shop_count shop_right"><a><span class="my_record">兑换记录</span></a></div>
    </div>

    <!-- 秒杀专区 -->
    <div id="seckill_div">
        <div class="seckill_title">
            <div class="seckill_left">秒抢专区</div>
            <div class="seckill_right" id="MeskillTimeDiv" style="display: none">
                <span class="countdown_time" id="time_d">00</span>
                <span class="countdown_break" id="time_d_1">:</span>
                <span class="countdown_time" id="time_h">00</span>
                <span class="countdown_break" id="time_d_2">:</span>
                <span class="countdown_time" id="time_m">59</span>
                <span class="countdown_break" id="time_d_3">:</span>
                <span class="countdown_time" id="time_s">09</span>
            </div>
            <div class="seckill_right" id="SnappedDiv"> </div>
            <input type="hidden" id="MeskillTime" value="" />
        </div>
        <div class="seckill_content" id="seckill_list"></div>
    </div>

    <img src="images/_banner.jpg" width="100%" alt="" />

    <!-- 热门兑换 -->
    <div class="foot_nav">
        <div class="foot_title">
            <div class="foot_left">热门兑换</div>
        </div>
        <div>
            <ul class="foot_ul" id="product_list"></ul>
        </div>
    </div>

    <div class="no_more" style='text-align:center;padding-top:10px;padding-bottom:10px;color:#999999;display:none'>没有更多了！</div>

    <script type="text/javascript">
        //$kk.popup("<span style='font-size:15px;'>公告：春节期间由于物流原因，积分商城暂停兑换<br/>给您带来的不便敬请谅解<span>", "ok", 30000);
        var apiUrl = "http://"+window.location.host+"/";
        var brokerKid = kk.queryString("brokerKid");
        var cityName = kk.queryString("cityName");
        var ver = new Date().getMilliseconds();
        $(function () {

            $(".item > a").attr("href", apiUrl + "award.html?v=" + ver + "&cityName=" + cityName);
            f_PointBalance();
            //f_ProductExpand();
            //f_Category();
            f_ProductShow();
            f_Meskill();
            f_Alert("首页", cityName, brokerKid);
        });

        //获取剩余积分
        function f_PointBalance() {
            kk.api.get(apiUrl+"/Point/Get", function (data) {
                $("#PointBalance").text(data.F_PointBalance);
                $(".shop_left a").attr("href", apiUrl + "credit_detail.html?ver=" + ver);
                $(".shop_right a").attr("href", apiUrl + "change_histroy.html?ver=" + ver);
            });
        }
        //获取分类
        function f_Category() {
            kk.api.get(apiUrl+"/ProductsExpand/GetList", function (data) {
                $.each(data.Items, function (i, obj) {
                    picSelect(obj.Thumbs, obj.F_PicUrl, 40);
                    $("#category_list").append("<li><a href='" + timestamp(obj.F_ExpandUrl) + "'><img src='" + pic + "' alt='" + obj.F_ShowName + "' width='40' height='40'/><div class='icon_item'>" + obj.F_ShowName + "</div>");
                });
            });
        }
        function timestamp(url) {
            if (url.indexOf('?') > 0) {
                return url + "&ver=" + ver;
            } else {
                return url + "?ver=" + ver;
            }
        }

        //获取商品列表
        function f_ProductShow1() {
            kk.api.get(apiUrl+"/ProductShow/GetProductShow", { pageIndex: 1, pageSize: 5, isMeskill: 0 }, function (data) {
                $.each(data, function (i, obj) {
                   // picSelect(obj.Thumbs, obj.F_PicUrl, 135);
                    if (obj.F_InventoryNum > 0) {
                        $("#product_list").append("<li><a href='"+apiUrl+"goods_detail.html?ProductKid=" + obj.F_ProductKid + "&BrokerKid=" + brokerKid + "&cityName=" +
                            cityName + "'> <div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                            obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                            + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                            obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right'><span>马上抢</span></div> </div></div> </a></li>");
                    }
                    else {
                        $("#product_list").append("<li><div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                                                 obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                                                 + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                                                 obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right' click='return;'><span  class='goods_end'  >已兑完</span></div>  </div></div> </li>");
                    }
                });

            });
        }
        //禁止兑换
        function f_ProductShow() {
            kk.api.get(apiUrl + "/ProductShow/GetProductShow", { pageIndex: 1, pageSize: 5, isMeskill: 0 }, function (data) {
                $.each(data, function (i, obj) {
                    // picSelect(obj.Thumbs, obj.F_PicUrl, 135);

                    $("#product_list").append("<li><div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                                             obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                                             + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                                             obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right' click='return;'><span  class='goods_end'  >暂停兑换</span></div>  </div></div> </li>");

                });

            });
        }

        function f_Meskill() {
            var MeskillTime = "";
            var MeskillEndTime = "";
            var type = 1;
            kk.api.get(apiUrl+"/ProductShow/GetProductShow", { pageIndex: 1, pageSize: 3, isMeskill: 1 }, function (data) {
                if (data.length <= 0) {
                    $("#seckill_div").hide();
                } else {
                    $("#seckill_div").show();
                }
                var str = "";
                $.each(data, function (i, obj) {

                    MeskillTime = obj.F_BeginTime + " " + obj.F_ExchangeBeginTime;
                    var meskillEndTime = obj.F_EndTime + " " + obj.F_ExchangeEndTime;

                    if (f_Time2(MeskillTime, new Date().Format("yyyy/MM/dd hh:mm:ss"))) {
                        type = 1//距离开始倒计时
                    }
                    else if (f_Time(MeskillTime, meskillEndTime)) {
                        MeskillTime = meskillEndTime;
                        type = 2;//距离结束倒计时
                    }
                    else if (f_Time(meskillEndTime, new Date().Format("yyyy/MM/dd hh:mm:ss"))) {
                        type = 3;//秒杀结束
                    }
                    var divs = obj.F_InventoryNum > 0 ? "<div class=\"seckill_end\"></div>" : "<div class=\"seckill_end\" style=\"display:block;\"></div>";
                   // picSelect(obj.Thumbs, "http://testtop.tops001.com:3000" + obj.F_PicUrl);
                    switch (i) {
                        case 0:
                            str += "   <div class=\"seckill_content_left\">" +
                                divs +
                                  "                    <a href=\""+apiUrl+"goods_detail.html?ProductKid=" + obj.F_ProductKid + "&BrokerKid=" + brokerKid + "&cityName=" + cityName + "\">" +
                                  "                        <img src=\"" + obj.F_PicUrl + "\" alt=\"" + obj.F_ShowName + "\"  />" +
                                  "                    </a>" +
                                  "                </div>";
                            break;
                        case 1:
                            str += "                <div class=\"seckill_content_right seckill_content_line\">" +
                                 divs +
                                  "                    <a href=\""+apiUrl+"goods_detail.html?ProductKid=" + obj.F_ProductKid + "&BrokerKid=" + brokerKid + "&cityName=" + cityName + "\">" +
                                  "                        <img src=\"" + obj.F_PicUrl + "\" alt=\"" + obj.F_ShowName + "\"  />" +
                                  "                    </a>" +
                                  "                </div>";
                            break;
                        case 2:
                            str += "                <div class=\"seckill_content_right\">" +
                                 divs +
                                  "                    <a href=\""+apiUrl+"goods_detail.html?ProductKid=" + obj.F_ProductKid + "&BrokerKid=" + brokerKid + "&cityName=" + cityName + "\">" +
                                  "                        <img src=\"" + obj.F_PicUrl + "\" alt=\"" + obj.F_ShowName + "\"  />" +
                                  "                    </a>" +
                                  "                </div>";
                            break;
                    }
                });
                $("#seckill_list").append(str);
                $("#MeskillTime").val(MeskillTime)
                countDown($("#MeskillTime").val(), "#time_d", "#time_h", "#time_m", "#time_s", type);

            });
        }

        function f_Time(beginDate, endDate) {
            var d1 = new Date(beginDate.replace(/\-/g, "\/"));
            var d2 = new Date(endDate.replace(/\-/g, "\/"));
            if (beginDate != "" && endDate != "" && d1 >= d2) {
                return false;
            }
            return true;
        }

        function f_Time2(beginDate, endDate) {
            var d1 = new Date(beginDate.replace(/\-/g, "\/"));
            var d2 = new Date(endDate.replace(/\-/g, "\/"));
            if (beginDate != "" && endDate != "" && d1 >= d2) {
                return true;
            }
            return false;
        }

        //到计时
        function countDown(time, day_elem, hour_elem, minute_elem, second_elem, type) {
            //if(typeof end_time == "string")
            time = time.replace('-', '/');
            time = time.replace('-', '/');
            var end_time = new Date(time).getTime();//月份是实际月份-1
            //current_time = new Date().getTime(),
            switch (type) {
                case 1:
                    $("#MeskillTimeDiv").prepend("<span class='countdown_text'>开始倒计时：</span>");
                    break;
                case 2:
                    $("#MeskillTimeDiv").prepend("<span class='countdown_text'>结束倒计时：</span>");
                    break;
                case 3:
                    $("#SnappedDiv").show();
                    $("#MeskillTimeDiv").hide();
                    break
            }

            sys_second = (end_time - new Date().getTime()) / 1000;
            var timer = setInterval(function () {
                if (sys_second > 0) {
                    $("#SnappedDiv").hide();
                    $("#MeskillTimeDiv").show();


                    f_ShowTime();//处理显示问题

                    sys_second -= 1;
                    var day = Math.floor((sys_second / 3600) / 24);
                    var hour = Math.floor((sys_second / 3600) % 24);
                    var minute = Math.floor((sys_second / 60) % 60);
                    var second = Math.floor(sys_second % 60);
                    day_elem && $(day_elem).text(day);//计算天
                    $(hour_elem).text(hour < 10 ? "0" + hour : hour);//计算小时
                    $(minute_elem).text(minute < 10 ? "0" + minute : minute);//计算分
                    $(second_elem).text(second < 10 ? "0" + second : second);// 计算秒
                } else {
                    clearInterval(timer);
                    $("#SnappedDiv").show();
                    $("#MeskillTimeDiv").hide();
                }
            }, 1000);
        }

        function f_ShowTime() {
            if ($("#time_d").html() == "0" || $("#time_d").html() == "00") {
                $("#time_d").hide();
                $("#time_d_1").hide();
            } else {
                $("#time_d").show();
                $("#time_d_1").show();
            }

            if (($("#time_d").html() == "0" || $("#time_d").html() == "00")&&($("#time_h").html() == "0" || $("#time_h").html() == "00")) {
                $("#time_h").hide();
                $("#time_d_2").hide();
            } else {
                $("#time_h").show();
                $("#time_d_2").show();
            }
            if (($("#time_d").html() == "0" || $("#time_d").html() == "00") && ($("#time_h").html() == "0" || $("#time_h").html() == "00") && ($("#time_m").html() == "0" || $("#time_m").html() == "00")) {
                $("#time_m").hide();
                $("#time_d_3").hide();
            } else {
                $("#time_m").show();
                $("#time_d_3").show();
            }
        }

        //日期格式
        Date.prototype.Format = function (format) {
            var o = {
                "M+": this.getMonth() + 1, //month
                "d+": this.getDate(),    //day
                "h+": this.getHours(),   //hour
                "m+": this.getMinutes(), //minute
                "s+": this.getSeconds(), //second
                "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
                "S": this.getMilliseconds() //millisecond
            }
            if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
            (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o) if (new RegExp("(" + k + ")").test(format))
                format = format.replace(RegExp.$1,
                RegExp.$1.length == 1 ? o[k] :
                ("00" + o[k]).substr(("" + o[k]).length));
            return format;
        }

        //加载中..
        //$(function () {
        //    str = "<div class='fadeout'>" +
        //        "<div class='fadeout_middle'>" +
        //        "<div class='shape opr-texiao-rotate'></div>" +
        //        "</div>" +
        //        "<div class='logo_mid'></div>" +
        //        "</div>";
        //    $("body").append(str);
        //    setTimeout(function () { $(".fadeout").remove(); $(".lay100").slideDown(500); }, 500);
        //});
        //获取商品推广
        function f_ProductExpand() {
            kk.api.get(apiUrl+"/ProductsExpand/GetList", function (data) {
                $.each(data, function (i, obj) {
                    $("#owl-demo").append("<div class='item'><img src='images/banner_01.jpg' title='" + obj.F_ShowName + "' alt='" + obj.F_ShowName + "'/></div>");
                });
            });
        }

        //刷新页面
        initialize = function () {
            //window.location.reload();
            f_PointBalance();
        }
    </script>
    <script type="text/javascript">
        $("#preContent").width($(document).width());
        $(document).ready(function () {
            $("#owl-demo").owlCarousel({
                navigation: true,
                slideSpeed: 300,
                paginationSpeed: 400,
                singleItem: true,
                autoPlay: true,
                stopOnHover: true,
                navigation: false

                // "singleItem:true" is a shortcut for:
                // items : 1,
                // itemsDesktop : false,
                // itemsDesktopSmall : false,
                // itemsTablet: false,
                // itemsMobile : false
            });
        });

        function showFullImg(img) {
            $("#imghx").css("top", document.body.scrollTop + ($(window).height() - $(img).height()) / 2);
            $("#imghx").attr("src", $(img).attr("src"));
            //$("#fullImg").css("background-image", "url(" + img + ")");
            //$("#fullImg").css("backgroundPositionY", document.body.scrollTop + ($(window).height() - 450) / 2);
            $("#fullImg").height($(document).height());
            $("#fullImg").toggle();

            //$("body,html").bind('touchmove', function () {
            //    event.preventDefault();
            //});
        }
        function hideFullImg() {
            $("#fullImg").toggle();
            //$("body,html").unbind('touchmove');
        }
    </script>

    <script src="js/owl.carousel.min.js" type="text/javascript"></script>    
    <script>
        var page = 2;
        var flag = true
        function getData1() {
            kk.api.get(apiUrl + "/ProductShow/GetProductShow", { pageIndex: page++, pageSize: 5, isMeskill: 0 }, function (data) {
                var str = "";

                $.each(data, function (i, obj) {

                    if (obj.F_InventoryNum > 0) {

                        str += "<li class='opacity'><a href='" + apiUrl + "goods_detail.html?ProductKid=" + obj.F_ProductKid + "&BrokerKid=" + brokerKid + "&cityName=" +
                            cityName + "'> <div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                            obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                            + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                            obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right'><span>马上抢</span></div> </div></div> </a></li>";

                    }
                    else {
                        str += "<li class='opacity'><div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                                                 obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                                                 + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                                                 obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right' click='return;'><span  class='goods_end'  >已兑完</span></div>  </div></div> </li>";
                    }
                });
                flag = true;
                $("#product_list").append(str);
                $('body').animate({ top: "0px" });
                if (data.length < 5) {
                    $(".no_more").show();
                }
                //me.resetload();

            });
        }

        function getData() {
            kk.api.get(apiUrl + "/ProductShow/GetProductShow", { pageIndex: page++, pageSize: 5, isMeskill: 0 }, function (data) {
                var str = "";

                $.each(data, function (i, obj) {


                    str += "<li class='opacity'><div class='good_img'><img src='" + obj.F_PicUrl + "' alt='" + obj.F_ShowName + "' width='140' height='105'/></div><div class='goods_box'><div class='box_top'><div class='goods_title'>" +
                                             obj.F_ShowName + "</div><div class='goods_num'><span class='goods_price'>" + obj.F_PointNum
                                             + "</span><span class='goods_price_grey'>积分</span></div></div><div class='box_bttom'><div class='box_bottom_left'><div><span>已抢" + obj.ExchangeNum + "件</span></div><div><span>剩余" +
                                             obj.F_InventoryNum + "件</span></div></div><div class='box_bottom_right' click='return;'><span  class='goods_end'  >暂停兑换</span></div>  </div></div> </li>";

                });
                flag = true;
                $("#product_list").append(str);
                $('body').animate({ top: "0px" });
                if (data.length < 5) {
                    $(".no_more").show();
                }
                //me.resetload();

            });
        }
        
        window.onscroll = function() {
            if(document.body.scrollHeight - $(window).height() - $(window).scrollTop() < 50 && flag) {
                flag = false;
                getData()
            }
        }
        
    </script>

    <!--<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>-->
    <script type="text/javascript">
        function f_Alert(title, cityName, brokerKid) {
            //var nowTime = new Date().toString("yyyy-MM-dd HH:mm:ss");
            var ip = '';//returnCitySN["cip"];
            var before_url = document.referrer;
            var url = location.href;
            var str = {
                url: url,
                beforeUrl: before_url,
                city: cityName,
                tag:title
            }
            //var str = "{\"messagekey\":\"f566f401-7dfc-454d-b57a-00692c8289e7\",\"checkcode\":\"123456\",\"messagetype\":\"1\",\"topic\":\"CLUB:EMBEDD:QUEUE\",\"sendtime\":\"" + nowTime + "\",\"sender\":\"TmallEmbedd\",\"createtime\":\"" + nowTime + "\",\"messagecontent\":{\"user_id\":\"" + brokerKid + "\",\"sent_time\":\"" + nowTime + "\",\"url\":\"" + url + "\",\"ip\":\"" + ip + "\",\"tag\":\"" + title + "\",\"brfore_url\":\"" + brfore_url + "\",\"city_name\":\"" + cityName + "\"}}";
            //kk.api.add("a", apiUrl);
            //kk.api.a.post("ExternalVisit/VisitPointStore", str);
        }
    </script>
</body>

</html>
